package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true) //callSuper = true 表示不调用父类的 equals() 和 hashCode() 方法。
public class ControllerException extends  RuntimeException{
    private  Integer code;
    private  String message;
    // 该无参构造方法是为了序列化
    public ControllerException() {
    }

    public ControllerException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }

}
